home *** CD-ROM | disk | FTP | other *** search
/ Network Supervisor's Toolkit / Network Supervisor's Toolkit.iso / tools / nwtp06 / nwmess.pas < prev    next >
Pascal/Delphi Source File  |  1996-07-10  |  10KB  |  309 lines

  1. {$X+,B-,V-} {essential compiler directives}
  2.  
  3. UNIT nwMess;
  4.  
  5. { nwMess unit as of 950301 / NwTP 0.6 API. (c) 1993,1995, R.Spronk }
  6.  
  7. INTERFACE
  8.  
  9. Uses nwIntr,nwMisc;
  10.  
  11. { Primary functions:                    Interrupt: comments:
  12.  
  13. * BroadcastToConsole                    (F215/09)
  14. * GetBroadcastMessage                   (F215/01)
  15. * GetBroadcastMode                      (DE..(..04))
  16. * SendBroadcastMessage                  (F215/00)
  17. * SendConsoleBroadcast                  (F217/D1)
  18. * SetBroadcastMode                      (DE..(..0x)), x= 0,1,2,3
  19.  
  20.   Secondary Functions:
  21.  
  22. * SendMessageToUser
  23.  
  24.   Not implemented:
  25.  
  26. - CheckPipeStatus                       (F215/08)  (1)
  27. - CloseMessagePipe                      (F215/07)  (1)
  28. - DisableStationBroadcast               (F215/02)  (3)
  29. - EnableStationBroadcast                (F215/03)  (3)
  30. - GetPersonalMessage                    (F215/05)  (1)
  31. - LogNetworkMessage                     (F215/0D)  (2)
  32. - OpenMessagePipe                       (F215/06)  (1)
  33. - SendPersonalMessage                   (F215/04)  (1)
  34.  
  35. Notes:
  36.  (1) These calls are NOT supported by Netware 386 versions shipped after
  37.      December 1990, because they use pipe mechanisms, which cause a
  38.      considerable deal of server overhead.
  39.      These functions are not implemented in this unit.
  40.      Use IPX/SPX peer-to-peer communication instead (nwIPX,nwSPX,nwPEP).
  41.  (2) Network msg file no longer supported by 3.x
  42.  (3) Not supported by Netware 3.x. Use SetBroadcastMode instead.
  43. }
  44.  
  45. Var result:word;
  46.  
  47. {F215/09 [2.15c+]}
  48. Function BroadcastToConsole(message:string):boolean;
  49. { broadcast a message to the file server console. }
  50.  
  51. {F215/01 [2.15c+]}
  52. Function GetBroadcastMessage(var bmessage: string):boolean;
  53. { Reads a broadcast message strored at server }
  54.  
  55. {DE..(..04) [1.x/2.x/ 3.x]}
  56. Function GetBroadcastMode(var bmode:byte):boolean;
  57. { Returns the message mode. }
  58.  
  59. {F215/00 [2.15c+]}
  60. Function SendBroadcastMessage( message:string;
  61.                                connCount:byte;
  62.                                connList:TconnectionList;
  63.                                VAR resultlist:TconnectionList ):boolean;
  64. { Sends a broadcast message to a number of logical connections. }
  65.  
  66. {DE..(..0n) n=0,1,2,3 [1.x/2.x/3.x]}
  67. Function SetBroadcastMode(bmode:byte):boolean;
  68.  
  69. {F217/D1 [2.15c+]}
  70. Function SendConsoleBroadcast(message:string; connCount:byte;
  71.                               connList:TconnectionList       ):boolean;
  72. { Sends a message to a number of connections, as if the message was send
  73.  by a console broadcast command. Console oprator privileges required. }
  74.  
  75. {--------------------Secondary Functions-------------------------------}
  76.  
  77. Procedure SendMessageToUser(UserName,Message:String);
  78. { sends a message to a (group of) users.
  79.   The username may contain wildcards (* and ?).
  80.   The message will not be received by stations whose status is CASTOFF.}
  81.  
  82.  
  83. IMPLEMENTATION {============================================================}
  84.  
  85. USES nwConn;
  86.  
  87. {DE..(..04) [1.x/2.x/ 3.x]}
  88. Function GetBroadcastMode(var bmode:byte):boolean;
  89. { Returns the message mode.
  90.  
  91.   00 Server Stores : Netware Messages and User Messages,
  92.      Shell automaticly displays messages.
  93.   01 Server Stores : Server Messages. (User messages discarded)
  94.      Shell automaticly displays messages.
  95.   02 Server stores : Server messages only.
  96.      Applications have to use GetBroadCastMessage to see if there is a message.
  97.   03 Server stores : Server messages and User messages.
  98.      Applications have to use GetBroadCastMessage to see if there is a message. }
  99. var regs : TTregisters;
  100. begin
  101. regs.ah := $de;
  102. regs.dl := $04;
  103. RealModeIntr($21,regs);
  104. bmode := regs.al;
  105. result:=$00; { the call has no return codes }
  106. GetBroadCastMode:=True;
  107. end;
  108.  
  109.  
  110. {DE..(..0n) n=0,1,2,3 [1.x/2.x/3.x]}
  111. Function SetBroadcastMode(bmode:byte):boolean;
  112. { Sets the new message mode.
  113.  
  114.   possible resultcode: $FF ( illegal broadcastmode supplied or
  115.                              the broadcastmode after the call is not equal
  116.                              to the intended broadcast mode )
  117.  
  118.   00 Server Stores : Netware Messages and User Messages,
  119.      Shell automaticly displays messages.
  120.   01 Server Stores : Server Messages. (User messages discarded)
  121.      Shell automaticly displays messages.
  122.   02 Server stores : Server messages only.
  123.      Applications have to use GetBroadCastMessage to see if there is a message.
  124.   03 Server stores : Server messages and User messages.
  125.      Applications have to use GetBroadCastMessage to see if there is a message.     }
  126. var regs : TTregisters;
  127. begin
  128. if (bmode <4)
  129.  then begin
  130.       regs.ah := $de;
  131.       regs.dl := bmode;
  132.       RealModeIntr($21,regs);
  133.       if regs.al<>bmode  { if confirmation of new mode unequal desired mode }
  134.        then result:=$FF
  135.        else result:=$00;
  136.       end
  137.  else result:=$FF;
  138. SetBroadcastMode:=(result=0);
  139. end;
  140.  
  141.  
  142.  
  143. {F215/01 [2.15c+]}
  144. Function GetBroadcastMessage(var bmessage: string):boolean;
  145. { An application should poll this to see if there is a broadcastmessage
  146.   stored (for this workstation) at the default server.
  147.   The message mode must be 2 or 3. (No Notification by Shell)
  148.   If no message was stored at the server, or the message was empty,
  149.   this function will return FALSE and an errorcode of $103. }
  150. Type Treq=record
  151.           len      :word;
  152.           subF     :byte;
  153.           end;
  154.      Trep=record
  155.           _message:string[55];
  156.           end;
  157.      TPreq=^Treq;
  158.      TPrep=^Trep;
  159. BEGIN
  160. With TPreq(GlobalreqBuf)^
  161.  do begin
  162.     subF:=$01;
  163.     len:=1;
  164.     end;
  165. F2SystemCall($15,sizeOf(Treq),sizeOf(Trep),result);
  166. If result=0
  167.  then bmessage:=TPrep(GlobalReplyBuf)^._message;
  168.  
  169. if bmessage[0]=#0 then result:=$103; { whups! empty message }
  170.  
  171. GetBroadCastMessage:=(result=0);
  172. { returncodes:
  173.   00 Successful; FC Message Queue Full;
  174.   FE I/O failure: Lack of dynamic workspace.
  175.   103 No msgs stored at server. }
  176. end;
  177.  
  178.  
  179. {F215/00 [2.15c+]}
  180. Function SendBroadcastMessage( message:string;
  181.                                connCount:byte;
  182.                                connList:TconnectionList;
  183.                                VAR resultlist:TconnectionList ):boolean;
  184. { Sends a broadcast message to a number of logical connections.
  185.   The connectionlist is an array[1..connCount] of logical connection numbers,
  186.   the result of the broadcast can be found in the resultList parameter.
  187.   example:
  188.     connCount=5
  189.     connList=  [ 4,9,1,5,2 ]
  190.  
  191.     resultList= [$00, $00, $FC, $FD, $FF]
  192.  
  193.     possible codes in resultList:
  194.       $00: broadcast to this logical connnection was successful.
  195.       $FC: message rejected, buffer for this station already contains a message,
  196.       $FD: invalid connection number
  197.       $FF: The target connection has blocked incoming messages,
  198.            or the target connection is not in use. }
  199. Type Treq=record
  200.           len      :word;
  201.           subF     :byte;
  202.           _connCount     :byte;
  203.           connLandMessage:array[1..306] of byte; { 250 conn, 56 msg }
  204.           end;
  205.      Trep=record
  206.           connCount:byte;
  207.           _ResultList:TconnectionList;
  208.           end;
  209.      TPreq=^Treq;
  210.      TPrep=^Trep;
  211. Var t:byte;
  212. BEGIN
  213. With TPreq(GlobalReqBuf)^
  214.  do begin
  215.     subF:=$00;
  216.     _connCount:=connCount;
  217.     move(connList[1],connLandMessage[1],connCount);
  218.     t:=ord(message[0]); if t>55 then t:=55;
  219.     move(message[0],connLandMessage[connCount+1],t+1);
  220.     len:=3+connCount+t; { 2 bytes + [connList] + len(str) + str[0] }
  221.     end;
  222. F2SystemCall($15,sizeOf(Treq),sizeOf(Trep),result);
  223. If result=0
  224.  then with TPrep(GlobalReplyBuf)^
  225.       do resultList:=_resultlist;
  226. SendBroadcastMessage:=(result=0);
  227. end;
  228.  
  229.  
  230. {F215/09 [2.15c+]}
  231. Function BroadcastToConsole(message:string):boolean;
  232. { broadcast a message to the file server console.
  233.   The message (max 60 chars, in ascii range [$20..$7E]) will be displayed
  234.   at the bottom of the console screen.
  235.   This function truncates the messagelength to 60 and repaces illegal
  236.   characters with a . }
  237. Type Treq=record
  238.           len      :word;
  239.           subF     :byte;
  240.           _message :string;
  241.           end;
  242.      TPreq=^Treq;
  243. Var t:byte;
  244. BEGIN
  245. With TPreq(GlobalReqBuf)^
  246.  do begin
  247.     subF:=$09;
  248.     PstrCopy(_message,message,60);
  249.     for t:=1 to 60
  250.       do if (_message[t]<>#$0) and
  251.             ((_message[t]<#$20) or (_message[t]>#$7E))
  252.          then _message[t]:='.';
  253.     len:=62;
  254.     end;
  255. F2SystemCall($15,sizeOf(Treq),0,result);
  256. BroadcastToConsole:=(result=0);
  257. { resultcodes:  00 success ; $FC message queue full ;
  258.                $FE I/O failure: lack of dynamic workspace }
  259. end;
  260.  
  261.  
  262. {F217/D1 [2.15c+]}
  263. Function SendConsoleBroadcast(message:string; connCount:byte;
  264.                               connList:TconnectionList       ):boolean;
  265. {Sends a message to a number of connections, as if the message was send
  266.  by a console oprator. Console operator privileges required.
  267.  If connCount equals 0, then the message is send to all connections. }
  268. Type Treq=record
  269.           len      :word;
  270.           subF     :byte;
  271.           _ConnCount:byte;
  272.           _connAndMess:array[1..306] of byte;
  273.           end;
  274.     TPreq=^Treq;
  275. Var t:byte;
  276. BEGIN
  277. With TPreq(GlobalReqBuf)^
  278.  do begin
  279.     subF:=$D1;
  280.     _connCount:=connCount;
  281.     Move(connList[1],_connAndMess[1],connCount);
  282.     t:=ord(message[0]); if t>55 then t:=55;
  283.     {!! to do: strip hi-bit of message.. }
  284.     Move(message[0],_connAndMess[connCount+1],t+1);
  285.     len:=t+connCount+3;
  286.     end;
  287. F2SystemCall($17,sizeOf(Treq),0,result);
  288. SendConsoleBroadcast:=(result=0);
  289. {Resultcodes: $00 success; $C6 No Console Rights}
  290. end;
  291.  
  292. {=================== Secondary Functions ===================================}
  293.  
  294. Procedure SendMessageToUser(UserName,Message:String);
  295. { sends a message to a (group of) users.
  296.   The username may contain wildcards (* and ?).
  297.   The message will not be received by stations whose status is CASTOFF.}
  298. { calls nwConn.getObjectConnectionNumber and nwMess.SendBroadcastMessage }
  299. Var NbrOfConn:byte;
  300.     connList,ResultList:TconnectionList;
  301. begin
  302. IF NwConn.GetObjectConnectionNumbers(UserName,1 {OT_USER},NbrOfConn,connList)
  303.    AND (NbrOfConn>0)
  304.  then SendBroadcastMessage(Message,NbrOfConn,connList,ResultList);
  305. end;
  306.  
  307.  
  308. end. {unit nwMess}
  309.